<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is for FFTW
(version 3.3.8, 24 May 2018).

Copyright (C) 2003 Matteo Frigo.

Copyright (C) 2003 Massachusetts Institute of Technology.

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation
approved by the Free Software Foundation. -->
<!-- Created by GNU Texinfo 6.3, http://www.gnu.org/software/texinfo/ -->
<head>
<title>FFTW 3.3.8: MPI Data Distribution Functions</title>

<meta name="description" content="FFTW 3.3.8: MPI Data Distribution Functions">
<meta name="keywords" content="FFTW 3.3.8: MPI Data Distribution Functions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="FFTW-MPI-Reference.html#FFTW-MPI-Reference" rel="up" title="FFTW MPI Reference">
<link href="MPI-Plan-Creation.html#MPI-Plan-Creation" rel="next" title="MPI Plan Creation">
<link href="Using-MPI-Plans.html#Using-MPI-Plans" rel="prev" title="Using MPI Plans">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<a name="MPI-Data-Distribution-Functions"></a>
<div class="header">
<p>
Next: <a href="MPI-Plan-Creation.html#MPI-Plan-Creation" accesskey="n" rel="next">MPI Plan Creation</a>, Previous: <a href="Using-MPI-Plans.html#Using-MPI-Plans" accesskey="p" rel="prev">Using MPI Plans</a>, Up: <a href="FFTW-MPI-Reference.html#FFTW-MPI-Reference" accesskey="u" rel="up">FFTW MPI Reference</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="MPI-Data-Distribution-Functions-1"></a>
<h4 class="subsection">6.12.4 MPI Data Distribution Functions</h4>

<a name="index-data-distribution-5"></a>
<p>As described above (see <a href="MPI-Data-Distribution.html#MPI-Data-Distribution">MPI Data Distribution</a>), in order to
allocate your arrays, <em>before</em> creating a plan, you must first
call one of the following routines to determine the required
allocation size and the portion of the array locally stored on a given
process.  The <code>MPI_Comm</code> communicator passed here must be
equivalent to the communicator used below for plan creation.
</p>
<p>The basic interface for multidimensional transforms consists of the
functions:
</p>
<a name="index-fftw_005fmpi_005flocal_005fsize_005f2d-2"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize_005f3d"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize_005f2d_005ftransposed-1"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize_005f3d_005ftransposed-1"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize_005ftransposed"></a>
<div class="example">
<pre class="example">ptrdiff_t fftw_mpi_local_size_2d(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm,
                                 ptrdiff_t *local_n0, ptrdiff_t *local_0_start);
ptrdiff_t fftw_mpi_local_size_3d(ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2,
                                 MPI_Comm comm,
                                 ptrdiff_t *local_n0, ptrdiff_t *local_0_start);
ptrdiff_t fftw_mpi_local_size(int rnk, const ptrdiff_t *n, MPI_Comm comm,
                              ptrdiff_t *local_n0, ptrdiff_t *local_0_start);

ptrdiff_t fftw_mpi_local_size_2d_transposed(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm,
                                            ptrdiff_t *local_n0, ptrdiff_t *local_0_start,
                                            ptrdiff_t *local_n1, ptrdiff_t *local_1_start);
ptrdiff_t fftw_mpi_local_size_3d_transposed(ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2,
                                            MPI_Comm comm,
                                            ptrdiff_t *local_n0, ptrdiff_t *local_0_start,
                                            ptrdiff_t *local_n1, ptrdiff_t *local_1_start);
ptrdiff_t fftw_mpi_local_size_transposed(int rnk, const ptrdiff_t *n, MPI_Comm comm,
                                         ptrdiff_t *local_n0, ptrdiff_t *local_0_start,
                                         ptrdiff_t *local_n1, ptrdiff_t *local_1_start);
</pre></div>

<p>These functions return the number of elements to allocate (complex
numbers for DFT/r2c/c2r plans, real numbers for r2r plans), whereas
the <code>local_n0</code> and <code>local_0_start</code> return the portion
(<code>local_0_start</code> to <code>local_0_start + local_n0 - 1</code>) of the
first dimension of an n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;n<sub>d-1</sub>
 array that is stored on the local
process.  See <a href="Basic-and-advanced-distribution-interfaces.html#Basic-and-advanced-distribution-interfaces">Basic and advanced distribution interfaces</a>.  For
<code>FFTW_MPI_TRANSPOSED_OUT</code> plans, the &lsquo;<samp>_transposed</samp>&rsquo; variants
are useful in order to also return the local portion of the first
dimension in the n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&hellip;&times;&nbsp;n<sub>d-1</sub>
 transposed output.  
See <a href="Transposed-distributions.html#Transposed-distributions">Transposed distributions</a>.  
The advanced interface for multidimensional transforms is:
</p>
<a name="index-advanced-interface-5"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize_005fmany-1"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize_005fmany_005ftransposed-1"></a>
<div class="example">
<pre class="example">ptrdiff_t fftw_mpi_local_size_many(int rnk, const ptrdiff_t *n, ptrdiff_t howmany,
                                   ptrdiff_t block0, MPI_Comm comm,
                                   ptrdiff_t *local_n0, ptrdiff_t *local_0_start);
ptrdiff_t fftw_mpi_local_size_many_transposed(int rnk, const ptrdiff_t *n, ptrdiff_t howmany,
                                              ptrdiff_t block0, ptrdiff_t block1, MPI_Comm comm,
                                              ptrdiff_t *local_n0, ptrdiff_t *local_0_start,
                                              ptrdiff_t *local_n1, ptrdiff_t *local_1_start);
</pre></div>

<p>These differ from the basic interface in only two ways.  First, they
allow you to specify block sizes <code>block0</code> and <code>block1</code> (the
latter for the transposed output); you can pass
<code>FFTW_MPI_DEFAULT_BLOCK</code> to use FFTW&rsquo;s default block size as in
the basic interface.  Second, you can pass a <code>howmany</code> parameter,
corresponding to the advanced planning interface below: this is for
transforms of contiguous <code>howmany</code>-tuples of numbers
(<code>howmany = 1</code> in the basic interface).
</p>
<p>The corresponding basic and advanced routines for one-dimensional
transforms (currently only complex DFTs) are:
</p>
<a name="index-fftw_005fmpi_005flocal_005fsize_005f1d-1"></a>
<a name="index-fftw_005fmpi_005flocal_005fsize_005fmany_005f1d"></a>
<div class="example">
<pre class="example">ptrdiff_t fftw_mpi_local_size_1d(
             ptrdiff_t n0, MPI_Comm comm, int sign, unsigned flags,
             ptrdiff_t *local_ni, ptrdiff_t *local_i_start,
             ptrdiff_t *local_no, ptrdiff_t *local_o_start);
ptrdiff_t fftw_mpi_local_size_many_1d(
             ptrdiff_t n0, ptrdiff_t howmany,
             MPI_Comm comm, int sign, unsigned flags,
             ptrdiff_t *local_ni, ptrdiff_t *local_i_start,
             ptrdiff_t *local_no, ptrdiff_t *local_o_start);
</pre></div>

<a name="index-FFTW_005fMPI_005fSCRAMBLED_005fOUT-1"></a>
<a name="index-FFTW_005fMPI_005fSCRAMBLED_005fIN-1"></a>
<p>As above, the return value is the number of elements to allocate
(complex numbers, for complex DFTs).  The <code>local_ni</code> and
<code>local_i_start</code> arguments return the portion
(<code>local_i_start</code> to <code>local_i_start + local_ni - 1</code>) of the
1d array that is stored on this process for the transform
<em>input</em>, and <code>local_no</code> and <code>local_o_start</code> are the
corresponding quantities for the input.  The <code>sign</code>
(<code>FFTW_FORWARD</code> or <code>FFTW_BACKWARD</code>) and <code>flags</code> must
match the arguments passed when creating a plan.  Although the inputs
and outputs have different data distributions in general, it is
guaranteed that the <em>output</em> data distribution of an
<code>FFTW_FORWARD</code> plan will match the <em>input</em> data distribution
of an <code>FFTW_BACKWARD</code> plan and vice versa; similarly for the
<code>FFTW_MPI_SCRAMBLED_OUT</code> and <code>FFTW_MPI_SCRAMBLED_IN</code> flags.
See <a href="One_002ddimensional-distributions.html#One_002ddimensional-distributions">One-dimensional distributions</a>.
</p>
<hr>
<div class="header">
<p>
Next: <a href="MPI-Plan-Creation.html#MPI-Plan-Creation" accesskey="n" rel="next">MPI Plan Creation</a>, Previous: <a href="Using-MPI-Plans.html#Using-MPI-Plans" accesskey="p" rel="prev">Using MPI Plans</a>, Up: <a href="FFTW-MPI-Reference.html#FFTW-MPI-Reference" accesskey="u" rel="up">FFTW MPI Reference</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
